/// 用户数据模型
/// 包含用户的基本信息
class UserDataEntity {
  final String uniqueId;
  final String loginAccount;
  final String secretKey;
  final String displayName;
  final String personalBio;
  final String profileImage;

  const UserDataEntity({
    required this.uniqueId,
    required this.loginAccount,
    required this.secretKey,
    required this.displayName,
    required this.personalBio,
    required this.profileImage,
  });

  /// 从JSON创建用户对象
  factory UserDataEntity.fromJson(Map<String, dynamic> json) {
    return UserDataEntity(
      uniqueId: json['uniqueId'] as String,
      loginAccount: json['loginAccount'] as String,
      secretKey: json['secretKey'] as String,
      displayName: json['displayName'] as String,
      personalBio: json['personalBio'] as String,
      profileImage: json['profileImage'] as String,
    );
  }

  /// 转换为JSON
  Map<String, dynamic> toJson() {
    return {
      'uniqueId': uniqueId,
      'loginAccount': loginAccount,
      'secretKey': secretKey,
      'displayName': displayName,
      'personalBio': personalBio,
      'profileImage': profileImage,
    };
  }

  /// 复制用户对象并修改部分属性
  UserDataEntity copyWith({
    String? uniqueId,
    String? loginAccount,
    String? secretKey,
    String? displayName,
    String? personalBio,
    String? profileImage,
  }) {
    return UserDataEntity(
      uniqueId: uniqueId ?? this.uniqueId,
      loginAccount: loginAccount ?? this.loginAccount,
      secretKey: secretKey ?? this.secretKey,
      displayName: displayName ?? this.displayName,
      personalBio: personalBio ?? this.personalBio,
      profileImage: profileImage ?? this.profileImage,
    );
  }

  @override
  String toString() {
    return 'UserDataEntity(uniqueId: $uniqueId, loginAccount: $loginAccount, displayName: $displayName, personalBio: $personalBio)';
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;
    return other is UserDataEntity && other.uniqueId == uniqueId;
  }

  @override
  int get hashCode => uniqueId.hashCode;
}
